package movement;

import lejos.nxt.Button;
import lejos.nxt.LCD;
import protocol.Protocol;
import protocol.Protocol.Direction;
import sensors.Grid;
import sensors.LeftButtonListener;
import sensors.RightButtonListener;
import sensors.Touch;

public class Initialisation {

	Engine engine;

	public Engine getEngine() {
		return engine;
	}

	public Grid getGrid() {
		return grid;
	}

	public Touch getTouch() {
		return touch;
	}

	public Direction getDirection() {
		return Protocol.convertToDirection(direction);
	}

	Grid grid;
	Touch touch;
	double approximatedFieldSize;
	int direction;

	public Initialisation(double one, double two) {
		engine = new Engine(one, two);
		touch = new Touch();
		grid = new Grid();
		promptForDirection();
	}

	/**
	 * Asks for the initial Direction of the Agent
	 */
	private void promptForDirection() {
		LCD.drawString("Enter Direction", 0, 0);
		LeftButtonListener lbl = new LeftButtonListener();
		Button.LEFT.addButtonListener(lbl);
		RightButtonListener rbl = new RightButtonListener(lbl);
		Button.RIGHT.addButtonListener(rbl);

		while (!rbl.finished()) {
		}

		this.direction = lbl.getDirection();
		LCD.drawString("Direction: " + this.direction, 0, 3);
	}

}
